< Prev(J) / Next(K) > / View :

Filename: /text/swriter/01/04090200.xhp

(bookmark: bm_id3145828)
logical expressions
formulating conditions
conditions; in fields and sections
fields;defining conditions
sections;defining conditions
variables; in conditions
user data;in conditions
databases;in conditions
hiding; database fields

論理式
条件式の作成
条件式; フィールドやセクションで使用
フィールド;条件式の定義
セクション;条件式の定義
変数; 条件式で使用
ユーザーデータ;条件式で使用
データベース;条件式で使用
非表示; データベースフィールド

(variable: defining_conditions)Defining Conditions
(variable: defining_conditions)条件を設定する(hd_id3145828.1)

Conditions are logical expressions that you can use to control the display of fields and sections in your document. Although the following examples apply to fields, they also apply to sections.
条件式とは、論理演算を用いた判定式のことであり、ドキュメント内に配置するフィールドセクションの表示を制御する際に使用します。ここでの解説では例としてフィールドを使用していますが、セクションの場合でも同様です。(par_id3145242.13)

You can define conditions for the following field types:
条件は、次の種類のフィールドに設定できます。(par_id3147171.93)

  1. Conditional text: displays text A if the condition is true, or text B if the condition is false.
    条件付きテキスト:条件が真の場合はテキスト A を表示し、条件が偽の場合はテキスト B を表示します。(par_id3151185.14)

  2. Hidden text: hides the contents of the field if the condition is true.
    隠しテキスト:条件が真の場合、フィールドの内容を隠します (表示しません)。(par_id3149289.15)

  3. Hidden paragraph: hides the paragraph if the condition is true.
    隠し段落:条件が真の場合、段落の内容を隠します (表示しません)。(par_id3145412.16)

  4. Any record and next record: controls the access to database records.
    任意のレコードと次のレコード:データベースレコードへのアクセスを制御します。(par_id3147515.17)

The simplest way to define a condition is to type the logical expression directly in a Condition box using the following values:
条件を定義するもっとも簡単な方法は、次の値を使用して、入力ボックス 条件 に論理表現を直接入力することです。(par_id3149802.18)

TRUE
TRUE(par_id3153677.19)

The condition is always met. You can also enter any value not equal to 0 as the conditional text.
条件は常に満たされます。0 に等しくない任意の値を条件テキストとして指定することもできます。(par_id3152960.20)

FALSE
FALSE(par_id3155900.21)

The condition is not met. You can also enter the value 0.
条件は満たされません。0 値を指定することもできます。(par_id3154191.22)


Note Icon 注マーク If you leave the Condition box empty, the condition is interpreted as not being met.
入力ボックス 条件 を空のままにした場合、条件は「満たされない」ものであると見なされます。(par_id3147090.23)

When you define a condition, use the same elements for defining a formula, namely comparative operators, mathematical and statistical functions, number formats, variables and constants.
条件式の記述には、通常の数式の構成要素である、比較演算子、数学関数、統計関数、数の書式、変数、定数なども利用します。(par_id3148980.24)

You can use the following types of variables when you define a condition:
条件を定義するときには、次の種類の変数を使用できます。(par_id3153638.25)

  1. Predefined Office variables that use statistics on document properties
    Office の定義済み変数 (ドキュメントのプロパティーで得られる統計情報)(par_id3155135.27)

  2. Custom variables, that are a created with the "Set variable" field
    ユーザー定義の変数 (「変数の設定」フィールドで作成する)(par_id3156273.26)

  3. Variables based on user data
    ユーザーデータに基づく変数(par_id3149174.94)

  4. Variables based on the contents of database fields
    データベースフィールドの内容に基づく変数(par_id3145781.28)

You cannot use internal variables, such as page and chapter numbers, in condition expression.
ページ番号や章番号などの内部変数は条件式には使用できません。(par_id3155916.29)

Conditions and Variables
条件と変数(hd_id3151375.30)

The following examples use a variable called "x":
次の例では、変数「x」を使用しています。(par_id3150122.31)

x == 1 or x EQ 1
x== 1 または x EQ 1(par_id3147417.32)

The condition is true if "x" is equal to 1.
変数「x」が 1 に等しい場合、条件は真になります。(par_id3147500.33)

x != 1 or x NEQ 1
x != 1 または x NEQ 1(par_id3145259.34)

The condition is true if "x" does not equal 1.
変数「x」が 1 に等しくない場合、条件は真になります。(par_id3150551.35)

sinx == 0
sinx == 0(par_id3147749.36)

The condition is true if "x" is a multiple of pi.
変数「x」がパイの倍数である場合、条件は真になります。(par_id3146345.37)


To use comparative operators with strings, the operands must be bounded by double quotation marks:
比較演算子を文字列と一緒に使用するには、演算子を二重引用符で囲む必要があります。(par_id3149846.38)

x == "ABC" or x EQ "ABC"
x == "ABC" または x EQ "ABC"(par_id3151078.39)

Checks if variable "x" contains (true) the "ABC" string, or not (false).
変数「x」に文字列「ABC」が含まれているか (True)、そうでないか (false) を判定します。(par_id3150162.40)

x == "" or x EQ ""
x == "" または x EQ ""(par_id3153301.41)

or
あるいは(par_id3156120.90)

!x or NOT x
! x または NOT x(par_id3156133.42)

Checks if the variable "x" contains an empty string.
変数「x」に空の文字列が含まれている場合は真になります。(par_id3156112.44)


Note Icon 注マーク The "equal" comparative operator must be represented by two equal signs (==) in a condition. For example, if you define a variable "x" with the value of 1, you can enter the condition as x==1.
「等しい」ことを示す比較演算子を条件で使用する場合、2 つの等号記号 (==) で表現する必要があります。たとえば、値 1 を持つ変数「x」を定義した場合、「FALSE x==1」という条件を入力できます。(par_id3150097.45)

User Data
ユーザーデータ(hd_id3148791.95)

You can include user data when you define conditions. To change your user data, choose (in case of MAC)Office - Preferences(/in case of MAC)(in other case)Tools - Options(/in other case) - Office - User data. User data must be entered in the form of strings. You can query the user data with "==" (EQ), "!=" (NEQ), or "!"(NOT).
[PO-fuzzy@swriter\01.po] ※※※未訳※※※(par_id3150028.96)

The following table lists user data variables and their meanings:
次の表に、ユーザーデータの変数とその意味を示します。(par_id3153124.97)

Variable
変数(par_id3149632.130)

Meaning
説明(par_id3150662.131)

user_firstname
user_firstname(par_id3154026.98)

First name
(par_id3149953.99)

user_lastname
user_lastname(par_id3147272.100)

Last name
(par_id3149601.101)

user_initials
user_initials(par_id3150770.102)

Initials
イニシャル(par_id3155529.103)

user_company
user_company(par_id3148705.104)

Company
会社(par_id3148728.105)

user_street
user_street(par_id3155361.106)

Street
住所(par_id3154222.107)

user_country
user_country(par_id3145108.108)

Country
国名(par_id3146885.109)

user_zipcode
user_zipcode(par_id3149580.110)

Zip code
郵便番号(par_id3156241.111)

user_city
user_city(par_id3148922.112)

City
都道府県名(par_id3148945.113)

user_title
user_title(par_id3156053.114)

Title
肩書き(par_id3159219.115)

user_position
user_position(par_id3156435.116)

Position
部署(par_id3145178.117)

user_tel_work
user_tel_work(par_id3150797.118)

Business telephone number
勤務先の電話番号(par_id3150820.119)

user_tel_home
user_tel_home(par_id3150894.120)

Home telephone number
自宅の電話番号(par_id3155320.121)

user_fax
user_fax(par_id3154400.122)

Fax number
ファックス番号(par_id3153363.123)

user_email
user_email(par_id3153390.124)

E-mail address
E-Mail アドレス(par_id3154948.125)

user_state
user_state(par_id3145603.126)

State (not in all Office versions)
州名 (officename] のバージョンによって異なります)(par_id3150129.127)


For example, to hide a paragraph, text, or a section from a user with a specific initial, such as "LM", enter the condition: user_initials=="LM".
たとえば、特別なイニシャル (たとえば、「LM」) を持つユーザーの場合にのみ、段落、テキスト、またはセクションを隠すには、次の条件を入力します。user_initials=="LM".(par_id3150147.128)

Conditions and Database Fields
条件とデータベースフィールド(hd_id3154115.46)

You can define conditions for accessing databases, or database fields. For example, you can check the contents of a database field from a condition, or use database fields in logical expressions. The following table lists a few more examples of using databases in conditions:
条件式中では、データベース内のデータベースフィールドにアクセスすることもできます。たとえば条件式を用いて、データベースフィールドの内容を判定させたり、論理式の演算対象として、データベースフィールドを指定することができます。次の表は、条件式中でのデータベースの使用例を簡単にまとめたものです。(par_id3154128.47)

Example
(par_id3156066.132)

Meaning
意味(par_id3156088.133)

Database.Table.Company
データベース.テーブル.会社(par_id3155948.48)

Database.Table.Company NEQ ""
データベース.表.会社 NEQ ""(par_id3148673.91)

Database.Table.Company != ""
データベース.表.会社 != ""(par_id3148687.92)

The condition is true if the COMPANY field is not empty. (In the first example, no operator is required.)
データベースフィールド「会社」が空ではない場合、条件は真になります。(最初の例では、演算子は必要ありません。)(par_id3155373.49)

!Database.Table.Company
!データベース.表.会社(par_id3149977.7)

NOT Database.Table.Company
NOT データベース.テーブル.会社(par_id3149991.129)

Database.Table.Company EQ ""
データベース.表.会社 EQ ""(par_id3150004.50)

Database.Table.Company ==""
データベース.表.会社 ==""(par_id3146911.9)

Returns TRUE if the COMPANY field is empty.
COMPANY フィールドが空の場合、TRUE を返します。(par_id3148733.8)

Database.Table.Company !="Sun"
データベース.表.会社 !="Sun"(par_id3148762.5)

Database.Table.Company NEQ "Sun"
データベース.表.会社 NEQ "Sun"(par_id3153016.149)

Returns TRUE if the current entry in the COMPANY field is not "Sun". (Exclamation sign represents a logical NOT.)
COMPANY フィールド内の現在のエントリが、「Sun」でない場合、TRUE を返します。(感嘆符は論理否定を表します。)(par_id3153040.6)

Database.Table.Firstname AND Database.Table.Name
データベース.テーブル.名 AND データベース.テーブル.姓(par_id3154605.51)

Returns TRUE if the record contains the first and the last name.
レコードに最初の名前と最後の名前が入っている場合、TRUE を返します。(par_id3153059.52)


Note Icon 注マーク Note the difference between the boolean NOT "!" and the comparative operator not equal "!=" (NEQ).
論理否定 "!" (NOT) と比較演算子「等しくない」"!=" (NEQ) との違いに注意してください。(par_id3159247.53)

When you refer to a database field in a condition, use the form Databasename.Tablename.Fieldname. If one of the names contains a character that is an operator, such as a minus sign (-), enclose the name in square brackets, for example, Databasename.[Table-name].Fieldname. Never use spaces inside field names.
条件式中でデータベースフィールドを参照する場合は、「データベース名.表名.フィールド名」の形式で指定します。これらの名前の中に、マイナス記号 (-) などの演算子と重なる記号が使われている場合は、「Databasename.[Table-name].Fieldname」のように、名前を大かっこで囲みます。なお、フィールドの名前の中にはスペース記号は使えません。(par_id3153876.54)

Example: Hiding an Empty Database Field
例:空のデータベースフィールドを隠す(par_id3153891.55)

You may want to create a condition that hides an empty field, for example, if the COMPANY field is empty for some of the data records.
必要であれば、空のフィールドを表示しない条件も作成できます。たとえば、いくつかのデータレコードのうち、フィールド「会社」が空の場合には、次のように入力します。(par_id3150051.56)

Select the Hidden Paragraph list entry, and type the following condition: Addressbook.Addresses.Company EQ ""
隠し段落リスト項目を選択し、次の条件を入力します: アドレス帳.アドレス.会社 EQ ""(par_id3150067.57)

or type the following
あるいは、次のように入力します。(par_id3147110.150)

NOT Addressbook.Addresses.Company
NOT アドレス帳.アドレス.会社(par_id3147123.151)

If the COMPANY database field is empty, the condition is true and the paragraph is hidden.
フィールド「会社」が空の場合、条件は真になり、段落は隠されます。(par_id3147136.152)

Note Icon 注マーク To display hidden paragraphs on the screen, you can choose (in case of MAC)Office - Preferences(/in case of MAC)(in other case)Tools - Options(/in other case) - Office Writer - Formatting Aids, and clear the Fields: Hidden paragraphs check box.
[PO-fuzzy@swriter\01.po] ※※※未訳※※※(par_id3150232.58)

Examples of Conditions in Fields
フィールド内の条件の例(hd_id3145218.59)

The following examples use the Conditional text field, although they can be applied to any fields that can be linked to a condition. The syntax used for conditions is also used for the Hidden text, Hidden paragraph, Any record or Next record fields.
次の例では条件付きテキストフィールドを使用していますが、条件に関連するすべてのフィールドに共通です。条件の構文は、隠しテキスト、隠し段落、任意のレコード、または次のレコードの各フィールドにも適用できます。(par_id3145231.60)

To display conditional text based on the number of pages:
ページ数に基づいて条件付きテキストを表示するには、次のようにします。(hd_id3150311.61)

  1. Choose Insert - Fields - Other, and then click the Functions tab.
    メニュー 挿入 → フィールド → その他 を選択して、機能 タブをクリックします。(par_id3150333.136)

  2. In the Type list, click "Conditional text".
    リスト フィールドタイプ から「条件付きテキスト」を選択します。(par_id3147471.62)

  3. In the Condition box, type "page == 1".
    入力ボックス 条件 に「page == 1」と入力します。(par_id3154294.63)

  4. In the Then box, type "There is only one page".
    入力ボックス 条件を満たすとき に「1 ページしかありません。」と入力します。(par_id3154319.64)

  5. In the Or box, type "There are several pages".
    入力ボックス 条件を満たさないとき に「複数のページがあります。」と入力します。(par_id3150640.65)

  6. Click Insert, and then click Close.
    挿入 をクリックして、閉じる をクリックします。(par_id3153086.137)

To display conditional text based on a user-defined Variable
ユーザー定義の変数に基づいて条件付きテキストを表示するには、次のようにします。(hd_id3155814.67)

  1. Choose Insert - Fields - Other, and then click the Variables tab.
    メニュー 挿入 → フィールド → その他 を選択して、変数 タブをクリックします。(par_id3155836.138)

  2. In the Type list, click "Set Variable".
    リスト フィールドタイプ から「編集の設定」を選択します。(par_id3155109.68)

  3. In the Name box, type "Profit".
    入力ボックス 名前 に「利益」と入力します。(par_id3147008.139)

  4. In the Value box, type "5000".
    入力ボックス に「5000」と入力します。(par_id3147032.140)

  5. Click Insert.
    挿入 をクリックします。(par_id3152974.141)

  6. Click the Functions tab, and click "Conditional text" in the Type list.
    機能 タブをクリックして、リスト フィールドタイプ から「条件付きテキスト」を選択します。(par_id3152998.70)

  7. In the Condition box, type "Profit < 5000".
    入力ボックス 条件 に「利益 < 5000」と入力します。(par_id3150952.142)

  8. In the Then box, type "Target is not met".
    入力ボックス 条件を満たすとき に「該当するものはありません。」と入力します。(par_id3156291.71)

  9. In the Or box, type "Target is met".
    入力ボックス 条件を満たさないとき に「該当するものがありました。」と入力します。(par_id3156317.72)

  10. Click Insert.
    挿入 をクリックします。(par_id3154366.143)

To edit the contents of the "Profit" variable, double-click the variable field.
「利益」変数の内容を編集するには、変数フィールドをダブルクリックします。(par_id3154389.73)

To display conditional text based on the contents of a database field:
データベースフィールドの内容に基づいて条件付きテキストを表示するには、次のようにします。(hd_id3155573.74)

The first part of this example inserts a space between the "First Name" and "Last Name" fields in a document, and the second part inserts text based on the contents of a field. This example requires that an address data source is registered with Office.
この例の最初の部分ではドキュメントの「名」フィールドと「姓」フィールドの間に空白を挿入し、2 つ目の部分ではフィールドの内容にもとづいてテキストを挿入します。 この例は、Office に住所データソースが登録されていることが前提となります。(par_id3155587.144)

  1. Choose Insert - Fields - Other, and then click the Database tab.
    メニュー 挿入 → フィールド → その他 を選択して、データベース タブをクリックします。(par_id3150523.145)

  2. In the Type list, click "Mail merge fields".
    リスト フィールドタイプ から「差し込み印刷フィールド」を選択します。(par_id3148811.75)

  3. In the Database selection box, double-click an address book, click "First Name", and then click Insert. Repeat for "Last Name".
    入力ボックス データベースの選択 で「アドレス帳」をダブルクリックして、「名」を選択し、挿入 をクリックします。「姓」にも同様の手順を行います。(par_id3148841.76)

  4. In the document, place the cursor between the two fields, press Space, and then return to the Fields dialog:
    ドキュメント内の 2 つのフィールドの間にカーソルを置いて、スペースバーを押し、ダイアログ フィールド に戻ります。(par_id3147549.78)

  5. Click the Functions tab, and then click "Conditional text" in the Type list.
    機能 タブをクリックして、リスト フィールドタイプ から「条件付きテキスト」を選択します。(par_id3150416.79)

  6. In the Condition box, type: "Addressbook.addresses.firstname".
    入力ボックス 条件 に、「アドレス帳.アドレス.名」と入力します。(par_id3153589.146)

  7. In the Then box, type a space and leave the Or box blank.
    入力ボックス 条件を満たすとき に 1 文字のスペースを入力します。入力ボックス 条件を満たさないとき は空のままにします。(par_id3153615.80)

You can now use a condition to insert text based on the contents of the First Name field.
これで、「名」フィールドの内容に基づいて条件付きテキストを挿入できるようになりました。(par_id3153562.84)

  1. In the Fields dialog, click the Functions tab.
    ダイアログ フィールド で、機能 タブをクリックします。(par_id3150574.147)

  2. In the Type box, click "Conditional text".
    リスト フィールドタイプ から「条件付きテキスト」を選択します。(par_id3150605.85)

  3. In the Condition box, type: Addressbook.addresses.firstname == "Michael"
    入力ボックス 条件 に、「アドレス帳.アドレス.名 == "Michael"」と入力します。(par_id3151277.86)

  4. In the Then box, type "Dear".
    入力ボックス 条件を満たすとき に「前略」と入力します。(par_id3151303.87)

  5. In the Else box, type "Hello".
    条件を満たさないときボックスに「こんにちは」と入力します。(par_id3149138.88)

  6. Click Insert.
    挿入 をクリックします。(par_id3149163.148)


< Prev / Next >